.PHONY: build run stop clean docker-build docker-run docker-stop docker-clean composer-install

# Default target
all: docker-build docker-run

# Local PHP operations
composer-install:
	php composer.phar install

start:
	php example/invoke_workflow/index.php

# Docker operations
docker-build:
	docker build -t workflow-sdk-php .

docker-run:
	docker run --name workflow-sdk-php-container -d \
		-e CTYUN_AK=058e00ba5061498e855707ec4fc494b7 \
		-e CTYUN_SK=058e00ba5061498e855707ec4fc494b7 \
		-e CTYUN_REGION_ID=bb9fdb42056f11eda1610242ac110002 \
		workflow-sdk-php

docker-stop:
	docker stop workflow-sdk-php-container || true

docker-clean: docker-stop
	docker rm workflow-sdk-php-container || true
	docker rmi workflow-sdk-php || true

# Combined commands
build: composer-install

run: start

clean:
	rm -rf vendor

# Complete Docker workflow
docker-workflow: docker-clean docker-build docker-run

# View Docker container logs
docker-logs:
	docker logs workflow-sdk-php-container

# Enter Docker container shell
docker-shell:
	docker exec -it workflow-sdk-php-container bash